package com.dg11185.nearshop.activity.home;

import java.text.SimpleDateFormat;

import android.os.Bundle;
import android.os.Handler;
import android.widget.ListView;

import com.android.nearshop.R;
import com.dg11185.nearshop.activity.SubPageActivity;
import com.dg11185.nearshop.app.Utils;
import com.dg11185.nearshop.test.DemoData;
import com.dg11185.nearshop.view.adapter.F_ShopListAdapter;
import com.dg11185.nearshop.view.xlistview.XListView;
import com.dg11185.nearshop.view.xlistview.XListView.IXListViewListener;
import com.wlper.lib.uitls.ViewUtils;

/**
 * 精选商家子界面
 * 
 * @author wanliang527
 * @date 2014-5-9
 * @deprecated 原本在首页上是显示部分精选商家，提供入口到全部精选商家，现如今采用分页加载的模式，因此该界面不再使用了
 */
public class AllBrandShopsActvity extends SubPageActivity implements
        IXListViewListener {

    private XListView shopListView;

    private Handler mHandler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_all_brand_shops);
        setSubPageTitle("精选商家");
        shopListView = (XListView) findViewById(R.id.list_v_featured_shops);
        shopListView.setAdapter(new F_ShopListAdapter(this, DemoData
                .getSimpleShopList()));
        shopListView.setXListViewListener(this);

    }

    @Override
    public void onRefresh() {
        mHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                ViewUtils.showToast(getApplicationContext(), "刷新了");
                updateListView();
            }
        }, 2000);
    }

    @Override
    public void onLoadMore() {
        mHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                ViewUtils.showToast(getApplicationContext(), "加载更多");
                updateListView();
            }
        }, 2000);
    }

    private void updateListView() {
        shopListView.stopLoadMore();
        shopListView.stopRefresh();
        shopListView.setRefreshTime(Utils.getTime(new SimpleDateFormat(
                "yyyy年MM月dd日  HH:mm")));
    }

}
